import Vue from 'vue'
const vue = new Vue()

const TokenKey = 'User-Token'

export function getToken() {
  return vue.$pt.getStorageSync(TokenKey)
}

export function setToken(token) {
  return vue.$pt.setStorageSync(TokenKey, token)
}

export function clearStorageSync() {
  // 清除所有缓存
  return vue.$pt.clearStorageSync()
}

export function setMemberId(memberId) {
  vue.$pt.setStorageSync('memberId', memberId)
  // 储存响应式缓存
  vue.$store.commit('setMemberId', memberId)
}

export function setCustomerId(customerId) {
  vue.$pt.setStorageSync('customerId', customerId)
  // 储存响应式缓存
  vue.$store.commit('setCustomerId', customerId)
}

export function setPhone(phone) {
  vue.$pt.setStorageSync('phone', phone)
  // 储存响应式缓存
  vue.$store.commit('setPhone', phone)
}

// 支付类型
export function setPayMethod(payMethod) {
  vue.$pt.setStorageSync('payMethod', payMethod)
  // 储存响应式缓存
  vue.$store.commit('setPayMethod', payMethod)
}

export function setNickName(nickName) {
  vue.$pt.setStorageSync('nickName', nickName)
  // 储存响应式缓存
  vue.$store.commit('setNickName', nickName)
}

export function setAvatar(avatar) {
  vue.$pt.setStorageSync('avatar', avatar)
  // 储存响应式缓存
  vue.$store.commit('setAvatar', avatar)
}

export function setVisitorId(visitorId) {
  vue.$pt.setStorageSync('visitorId', visitorId)
  // 储存响应式缓存
  vue.$store.commit('setVisitorId', visitorId)
}

export function setEnterpriseId(enterpriseId) {
  vue.$pt.setStorageSync('enterpriseId', enterpriseId)
  // 储存响应式缓存
  vue.$store.commit('setEnterpriseId', enterpriseId)
}

export function setVeekrayStatus(veekrayStatus) {
  vue.$pt.setStorageSync('veekrayStatus', veekrayStatus)
  // 储存响应式缓存
  vue.$store.commit('setVeekrayStatus', veekrayStatus)
}

export function setCommanderStatus(commanderStatus) {
  vue.$pt.setStorageSync('commanderStatus', commanderStatus)
  // 储存响应式缓存
  vue.$store.commit('setCommanderStatus', commanderStatus)
}

export function setCommunityGroup(communityGroup) {
  vue.$pt.setStorageSync('communityGroup', communityGroup)
  // 储存响应式缓存
  vue.$store.commit('setCommunityGroup', communityGroup)
}

export function setStoreCardFlag(storeCardFlag) {
  vue.$pt.setStorageSync('storeCardFlag', storeCardFlag)
  vue.$store.commit('setStoreCardFlag', storeCardFlag)
}

export function setMemberNature(memberNature) {
  vue.$pt.setStorageSync('memberNature', memberNature)
  vue.$store.commit('setMemberNature', memberNature)
}

// 是否显示购买名片按钮
export function setShowBuyCard(showBuyCard) {
  vue.$pt.setStorageSync('showBuyCard', showBuyCard)
  // 储存响应式缓存
  vue.$store.commit('setShowBuyCard', showBuyCard)
}

export function setAppInfo(appInfo) {
  vue.$pt.setStorageSync('appInfo', appInfo)
  // 储存响应式缓存
  vue.$store.commit('setAppInfo', appInfo)
}

// 购物车角标
export function setCartBadge(cartBadge) {
  vue.$pt.setStorageSync('cartBadge', cartBadge)
  vue.$store.commit('setCartBadge', cartBadge)
}

// 快速购买商品列表
export function setFastGoods(fastGoods) {
  vue.$pt.setStorageSync('fastGoods', fastGoods)
  vue.$store.commit('setFastGoods', fastGoods)
}

// 底部导航列表
export function setNavList(navList) {
  vue.$pt.setStorageSync('navList', navList)
  vue.$store.commit('setNavList', navList)
}

// 分类链接
export function setCategoryInfo(categoryInfo) {
  vue.$pt.setStorageSync('categoryInfo', categoryInfo)
  // 储存响应式缓存
  vue.$store.commit('setCategoryInfo', categoryInfo)
}

// imToken
export function setImToken(imToken) {
  vue.$pt.setStorageSync('imToken', imToken)
  // 储存响应式缓存
  vue.$store.commit('setImToken', imToken)
}

// im卖家消息列表
export function setImSellerToList(imSellerToList) {
  vue.$pt.setStorageSync('imSellerToList', imSellerToList)
  vue.$store.commit('setImSellerToList', imSellerToList)
}

// im买家消息列表
export function setImBuyerToList(imBuyerToList) {
  vue.$pt.setStorageSync('imBuyerToList', imBuyerToList)
  vue.$store.commit('setImBuyerToList', imBuyerToList)
}

// im卖家会话总未读数
export function setImUnreadSeller(imUnreadSeller) {
  vue.$pt.setStorageSync('imUnreadSeller', imUnreadSeller)
  vue.$store.commit('setImUnreadSeller', imUnreadSeller)
}

// im买家会话总未读数
export function setImUnreadBuyer(imUnreadBuyer) {
  vue.$pt.setStorageSync('imUnreadBuyer', imUnreadBuyer)
  vue.$store.commit('setImUnreadBuyer', imUnreadBuyer)
}

// im有新消息
export function setInMessage(inMessage) {
  vue.$pt.setStorageSync('inMessage', inMessage)
  vue.$store.commit('setInMessage', inMessage)
}
